package com.datamation.swadeshi.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.datamation.swadeshi.R;
import com.datamation.swadeshi.control.data.ItemsDS;
import com.datamation.swadeshi.model.OrdDet;

public class OrderDetailsAdapter extends ArrayAdapter<OrdDet> {
	Context context;
	ArrayList<OrdDet> list;
	
	public OrderDetailsAdapter(Context context, ArrayList<OrdDet> list){
		
		super(context, R.layout.row_order_details, list);
		this.context = context;
		this.list = list;		
	}
	
	
	@Override
	public View getView(final int position, final View convertView, final ViewGroup parent) {
		
		LayoutInflater inflater = null;
		View row = null;
		
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		row = inflater.inflate(R.layout.row_order_details, parent, false);
		
		TextView item = (TextView) row.findViewById(R.id.row_item);
		TextView cases = (TextView) row.findViewById(R.id.row_cases);
		TextView piece = (TextView) row.findViewById(R.id.row_piece);
	
		ItemsDS ds =new ItemsDS(getContext());
		item.setText(ds.getItemNameByCode(list.get(position).getFORDDET_ITEM_CODE()));

		cases.setText(list.get(position).getFORDDET_CASE());
		piece.setText(list.get(position).getFORDDET_PICE_QTY());
		
		return row;
	}
}
